<?php 
function secure($string) {
	$string = strip_tags($string);
	$string = htmlspecialchars($string);
	$string = trim($string);
	$string = stripslashes($string);
	$string = mysql_real_escape_string($string);
	return $string;

}

################################################################
#                      Password generator                      #
#                                                              #
#                   Function by Jon Haworth                    #
#   Source: http://www.laughing-buddha.net/jon/php/password/   #
################################################################
function generatePassword ($length = 12)
{

  # start with a blank password
  $password = "";

  # define possible characters
  $possible = "0123456789bcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
    
  # set up a counter
  $i = 0; 
    
  # add random characters to $password until $length is reached
  while ($i < $length) { 

    # pick a random character from the possible ones
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
        
    # we don't want this character if it's already in the password
    if (!strstr($password, $char)) { 
      $password .= $char;
      $i++;
    }

  }

  # done!
  return $password;

}


function BytesToGreater($bytes){
	if    (strlen($bytes) < 4) {$bytes= number_format($bytes,2,',','').' b';} 
	elseif(strlen($bytes) < 7) {$bytes= number_format(($bytes/1024),2,',','').' Kb';} 
	elseif(strlen($bytes) < 10){$bytes= number_format(($bytes/1024/1024),2,',','').' Mb';} 
	elseif(strlen($bytes) < 13){$bytes= number_format(($bytes/1024/1024/1024),2,',','').' Gb';} 
	elseif(strlen($bytes) < 16){$bytes= number_format(($bytes/1024/1024/1024/1024),2,',','').' Tb';} 
	elseif(strlen($bytes) < 19){$bytes= number_format(($bytes/1024/1024/1024/1024/1024),2,',','').' Pb';} 
	elseif(strlen($bytes) < 21){$bytes= number_format(($bytes/1024/1024/1024/1024/1024/1024),2,',','').' Eb';} 
	elseif(strlen($bytes) < 24){$bytes= number_format(($bytes/1024/1024/1024/1024/1024/1024/1024),2,',','').' Zb';} 
	elseif(strlen($bytes) > 24){$bytes= number_format(($bytes/1024/1024/1024/1024/1024/1024/1024/1024),2,',','').' Yb';}
	return $bytes;
}
function SpecialsCharEncode($string){
	$string = str_replace('"', "%_SplChar02_%", $string);
	$string = str_replace("'", "%_SplChar01_%", $string);
	
	return $string;
}
function SpecialsCharDecode($string){
	$string = str_replace("%_SplChar01_%", "'", $string);
	$string = str_replace("%_SplChar02_%", '"', $string);
	
	return $string;
}

?>